#include <rclcpp/rclcpp.hpp>
#include <std_msgs/msg/string.hpp>

using namespace std::chrono_literals;

using String = std_msgs::msg::String;

class SimpleSubscriber: public rclcpp::Node
{
public:
  SimpleSubscriber(const std::string &node_name): Node(node_name)
  {
    sub_ = this->create_subscription<String>(
      "chater", 10, 
      std::bind(&SimpleSubscriber::subscriber_callback, this, std::placeholders::_1)
    );
    
    RCLCPP_INFO(this->get_logger(), "Subscriber is started");
  }

private :
  void subscriber_callback(const String &msg) const
  {
    RCLCPP_INFO_STREAM(this->get_logger(), "I heared: " << msg.data.c_str());
  }

  rclcpp::Subscription<String>::SharedPtr sub_;
};

int main(int argc, char *argv[])
{
  rclcpp::init(argc, argv);
  auto node = std::make_shared<SimpleSubscriber>("simple_publisher");
  rclcpp::spin(node);
  rclcpp::shutdown();

  return 0;
}